/***********************************************************************
publish mymessage
***********************************************************************/

#include <ros/ros.h>
#include "learning_topic/mymessage.h"

int main(int argc, char **argv)
{
    // ROS节点初始化
    ros::init(argc, argv, "publisher");

    // 创建节点句柄
    ros::NodeHandle n;

    // 创建一个Publisher，发布名为/info的topic，消息类型为learning_topic::mymessage，队列长度10
    ros::Publisher info_pub = n.advertise<learning_topic::mymessage>("/info", 10);

    // 设置循环的频率
    ros::Rate loop_rate(10);

    int count = 0;
    while (ros::ok())
    {
        // 初始化learning_topic::mymessage类型的消息
    	learning_topic::mymessage mymessage_msg;
		mymessage_msg.name = "cyq";
		mymessage_msg.id  = 1910.414;

        // 发布消息
		info_pub.publish(mymessage_msg);

       	ROS_INFO("Publish mymessage: name:%s  id:%.3f", 
				  mymessage_msg.name.c_str(), mymessage_msg.id);

        // 按照循环频率延时
        loop_rate.sleep();
    }

    return 0;
}


